package com.pet.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(MyMetaObjectHandler.class);

    @Override
    public void insertFill(MetaObject metaObject) {
        LOGGER.info("start insert fill ....");
        //this.setFieldValByName("createTime", new Date(), metaObject);
        //this.setFieldValByName("updateTime", new Date(), metaObject);
        //this.setFieldValByName("version", 1, metaObject);
        this.setFieldValByName("is_delete", 0, metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }

    @Override
    public MetaObjectHandler setFieldValByName(String fieldName, Object fieldVal, MetaObject metaObject) {
        return MetaObjectHandler.super.setFieldValByName(fieldName, fieldVal, metaObject);
    }

    @Override
    public Object getFieldValByName(String fieldName, MetaObject metaObject) {
        return MetaObjectHandler.super.getFieldValByName(fieldName, metaObject);
    }

    @Override
    public boolean openInsertFill() {
        return MetaObjectHandler.super.openInsertFill();
    }

    @Override
    public boolean openUpdateFill() {
        return MetaObjectHandler.super.openUpdateFill();
    }
}
